<template>
<div>
  <div class="table-data">
    <div class="search-box">
      <el-input size="small" v-model="code" placeholder="请输入核销码"></el-input>
      <el-button size="small" type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
      <!-- <el-button size="small" type="primary" @click="handleSearch">扫一扫</el-button> -->
      
    </div>
    <EditDialog :isAdd="isAdd" :form="formData" @closeDialog="closeDialog"></EditDialog>
  </div>
</div>
</template>

<script lang="ts">

import { Component, Vue, Provide,Prop,Watch } from "vue-property-decorator";
// import { State, Getter, Mutation, Action } from "vuex-class";

import EditDialog from "./EditDialog.vue";
import writeApi from "@/api/write";

@Component({
  components: {EditDialog }
})
export default class userList extends Vue {
  // @Getter("user") getUser: any;
  @Provide() tableData: any = []; // 表格数据
  @Provide() isAdd: Boolean = false; // 是否展示添加弹窗
  @Provide() loading: Boolean = true; // 是否显示加载图标
  @Provide() code:any=''
  @Provide() formData: any = []
  // 关闭弹窗
  closeDialog() {
    this.isAdd = false;
  }
  created() {
  }
  handleSearch(): void {
    // 点击搜索
    writeApi.writeOffQuery(this.code)
    .then((res: any) => {
      if(res.data.status==true){
        this.isAdd=true
        this.formData=res.data.data
        // this.code=''
      }else{
        this.$message({
          message: res.data.msg,
          type: "error"
        });
      }
    });
  }
}
</script>

<style lang="scss" scoped>
.el-range-editor.el-input__inner{
  margin-right: 10px
}
</style>
